import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export namespace WorkDynamics {
  /**查询参数 */
  export interface Query extends ReqPage {
    title?: string
    type?: number
    createTime?: any
    createTimeBegin?: string
    createTimeEnd?: string
  }

  /**列表内容 */
  export interface Record {
    id: number
    title: string
    type: number
    icon: string
    createTimeFormat: string
    longitude: string
    latitude: string
  }

  /**详情 */
  export interface Form {
    id: number
    title: string
    type: number
    icon: string
    longitude: string
    latitude: string
    content: string
    createTime: string
  }

  export const TypeEnum = [
    { value: 0, label: '走访慰问' },
    { value: 1, label: '产业引导' },
    { value: 2, label: '调处纠纷' },
    { value: 3, label: '挂包帮扶' }
  ]
}

// 分页查询
export const pageWorkDynamics = (params: WorkDynamics.Query) => {
  return http.get<ResPage<WorkDynamics.Record>>(TBY + `/work_dynamics/page`, params)
}

// 列表查询
export const listWorkDynamics = (params: WorkDynamics.Query) => {
  return http.get<WorkDynamics.Record[]>(TBY + `/work_dynamics/list`, params)
}

// 详情信息
export const getWorkDynamicsDetail = (id: number) => {
  return http.get<Partial<WorkDynamics.Form>>(TBY + `/work_dynamics/get`, { id }, { loading: false })
}

// 新增或修改
export const saveOrUpdateWorkDynamics = (params: Partial<WorkDynamics.Form>) => {
  return http.post(TBY + `/work_dynamics/save`, params)
}

// 删除
export const removeWorkDynamics = (id: number) => {
  return http.delete(TBY + `/work_dynamics/delete`, { id })
}
